<?php
	ini_set('error_reporting', e_notice);
    include_once "inc_function.php";
    include_once '../../function/class_tabel_paging.php';
    session_start();
	$action_tool = (isset($_REQUEST['auto']) && $_REQUEST['auto'] == true)?true:false;
    
?>
<body>
<script>
function cekValue(id,name){
	window.parent.window.get_employee(id,name);
	self.parent.tb_remove();
}
</script>
<fieldset class="list_superior">
   <legend> Dashboard List Superior</legend>
		<form action method='get' id=form_search>
		<div>Search : <input type='text' name='search' class='text_search' placeholder='search...' /></div>
		<?php if($action_tool){?>
		<input type="hidden" name="auto" value="true" />
		<?php }?>
		</form>
<?php
	$current_page = 1;
	if(isset($_GET['page'])){
		$current_page = $_GET['page'];
	}
	$page_per_row1 = 5;
	$start_myrow = ($current_page-1) * $page_per_row1 + 1;
	$end_row = $current_page * $page_per_row1;
	
	$sql_count = "SELECT COUNT(*) AS num_rows FROM view_emp_superior where employee_id > 0 order by employee_id asc";
	$headerValue = array(
		'OTHER' => array(
			'ID' => 'EMPLOYEE_ID',
			'NAME' => 'EMPLOYEE_NAME'		
		),
		'TABLE' => array(
			'EMPLOYEE NAME' => 'EMPLOYEE_NAME',
			'JOB TITLE' => 'JOB_TITLE_NAME',
			'MAIN COMPANY' => 'MAIN_COMPANY_NAME',
			'DIVISION NAME' => 'DIVISION_NAME',
		 )		
	);
	
	$search = (isset($_REQUEST['search'])) ?$_REQUEST['search']:''; 
	
	$sql1 = array(
		'sql_result' => "BEGIN PKG_MASTER.sp_get_superior_by_name(:str_employee_name,:int_start_row,:int_end_row,:cursor);END;",
		'condition' => array(
			':int_start_row' => $start_myrow,
			':int_end_row' => $end_row,
			':str_employee_name' => $search,
			':cursor' => ''	
		)
	);

	$paging = new tabel_paging($con,$sql_count,$page_per_row1,$sql1,$headerValue);
    $total_rows = $paging->count_rows($con,$sql_count);
    $total_mypages = $paging->total_pages($total_rows, $page_per_row1);
    echo $paging->paged_result($con,$start_myrow,$page_per_row1,$sql1,$headerValue);
?>
<div class="left">
<span class="right"><?php  echo $paging->draw_pager(AJAX_PATH."list_superior.php", $total_mypages, $current_page);?></span>
</div>
</fieldset>
</body>    